package com.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;

import com.obj.NewsInfo;

public class FilterAction implements Filter{

	public void destroy() {
		System.err.println("****对象销毁*********");
		
	}

	public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
			throws IOException, ServletException {
		System.err.println("****对象doFilter*********");
		HttpServletRequest req = (HttpServletRequest) arg0;
		HttpServletResponse response = (HttpServletResponse) arg1;
		response.addHeader("x-frame-options", "SAMEORIGIN");
		String pathInfo = req.getPathInfo() == null ? "" : req.getPathInfo();
		String url = req.getServletPath() + pathInfo;
		String uri = req.getRequestURI();
		String contentType = req.getContentType();
		System.out.println("*****进入后台*参数保存*****");
        System.err.println("****文章标题***");
        System.err.println("****简略标题***");
		//response.sendRedirect("index.html");
		arg2.doFilter(req, response);
	}
	
	public void init(FilterConfig arg0) throws ServletException {
		System.err.println("****对象init*********");
		
	}
	
}
